#include "lib.h"
#define GPJ2CON		(*(volatile unsigned int *)0xe0200280)
#define GPJ2DAT		(*(volatile unsigned int *)0xe0200284)

#define GPH2CON		(*(volatile unsigned int *)0xE0200C40)
#define GPH2DAT		(*(volatile unsigned int *)0xE0200C44)
#define GPH0CON		(*(volatile unsigned int *)0xE0200C00)
#define GPH0DAT 	(*(volatile unsigned int *)0xE0200C04)

#define GPBCON      (*(volatile unsigned int *)0xe0200040)
#define GPBDAT      (*(volatile unsigned int *)0xe0200044)

void led_init(void)
{
	GPBCON = 0x1111;
	GPH0CON &= ~((0xf<<(5*4)) | (0xf << (7*4)));
	GPH0CON |= ((0x1<<(5*4)) | (0x1 << (7*4)));
}

void led_water(void)
{
	int i = 0;
	while (1)
	{		
        if (0 == i) {
		    GPBDAT |= (1<<0);
        } else if(1 == i)  {
            GPBDAT |= (1<<2);
        } else if(2 == i)  {
            GPBDAT |= (1<<1);
        } else if(3 == i)  {
            GPBDAT |= (1<<3);
        } else if(4 == i)  {
            GPH0DAT |= (1<<7);
        } else if(5 == i)  {
            GPH0DAT |= (1<<5);
		} else if(6 == i)  {
            GPH0DAT &= ~(1<<5);
        } else if(7 == i)  {
            GPH0DAT &= ~(1<<7);
		} else if(8 == i)  {
            GPBDAT &= ~(1<<3);
        } else if(9 == i)  {
            GPBDAT &= ~(1<<1);
        } else if(10 == i)  {
            GPBDAT &= ~(1<<2);
        } else if(11 == i)  {
            GPBDAT &= ~(1<<0);
        }
		i++;
		if (i == 12)
			i = 0;
		delay();
	}

	return ;
}
